#!/usr/bin/env bash

main()
{
    # 防止执行僵死
    {
        sleep 100
    } &
    local pid=$!

    sleep 1

    kill -0 $pid
    if (( $? == 0 ))
    then
        echo "process $pid: $?"
        echo "process $pid: still exist, kill"
        kill $pid
        wait $pid &>/dev/null
        kill -0 $pid &>/dev/null
        echo "process $pid: $?"
    fi

    ps -f
}

main $@
exit $?
